package elijah.eupdater;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import java.util.Objects;


public class UpdateReceiver extends BroadcastReceiver {

    public static final String UPDATE_ACTION = "android.intent.action.PACKAGE_REPLACED";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Objects.equals(intent.getAction(), UPDATE_ACTION)) {
            Intent task = context.getPackageManager().getLaunchIntentForPackage(context.getApplicationContext().getPackageName());
            task.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(task);
        }

    }
}

